package com.markhsiu.MiniMQ.remote;

import com.markhsiu.MiniMQ.model.Message;
import com.markhsiu.MiniMQ.model.constant.MessageCmdEnum;
import com.markhsiu.MiniMQ.model.constant.MessageSourceEnum;

public abstract class AbstractMessageProcessor implements MessageProcessor{

	protected boolean checkMassage(Message message) {
		if(message.getCmd() == null){
			return false;
		}
		
		if(message.getSource() == MessageSourceEnum.CUSTOMER){
			if(message.getConsumerID() == null 
					|| message.getConsumerID().trim().length() == 0){
				return false;
			}
			if(message.getCmd() == MessageCmdEnum.SUB 
					|| message.getCmd() == MessageCmdEnum.UNSUB){
				if(message.getTopic() == null || 
						message.getTopic().trim().length() == 0){
					return false;
				}
			}
		}
		
		return true;
	}
}
